package com.se.util;

import cn.hutool.core.util.StrUtil;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MyDateUtil {
    public static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    public static boolean beforeCurrentTime(String timeStr) throws ParseException {
        Date time = sdf.parse(timeStr);
        return time.before(new Date());
    }

    public static boolean currentTimeBetween(String timeStr1, String timeStr2) throws ParseException {
        if(StrUtil.isBlank(timeStr1)){
            Date time = sdf.parse(timeStr2);
            return time.after(new Date());
        }else {
            Date time1 = sdf.parse(timeStr1);
            Date time2 = sdf.parse(timeStr2);
            Date time = new Date();
            return time1.before(time) && time2.after(time);
        }
    }
}
